package com.dyh.quickdemo.demos.lbdFactoryBean;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.function.Function;

/*
@Author=Joey Wheeler
@Date=2021/1/11 14:16
*/
//@Configuration
@Slf4j
public class FunctionFactoryBeanConfig  {



    @Bean
    FunctionFactoryBean functionFactoryBean(){
        FunctionFactoryBean functionFactoryBean = new FunctionFactoryBean();
        functionFactoryBean.setFunctionEnhancer(
                FunctionEnhancer.with(
                            e->{
                                if("114".equals(e))
                                    throw new RuntimeException();
                                log.info(e.toString());
                                return e+"!";
                            })
                        .hideException()
        );
        return functionFactoryBean;
    }

}
